﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using Forget.Data;

namespace Forget.HRBLL.Model
{
    public partial class HRLog
    {
        private static readonly string ADDHRLOG = "HR_AddHRLog";
        private static readonly string EDITHRLOG = "";
        private static readonly string DELHRLOG = "";


        #region properties
        [DataParam(32, System.Data.SqlDbType.Int)]
        public int? HRLogID { get; set; }
        [DataParam(30, System.Data.SqlDbType.NVarChar)]
        public string Source { get; set; }
        [DataParam(200, System.Data.SqlDbType.NVarChar)]
        public string Message { get; set; }
        [DataParam(500, System.Data.SqlDbType.NVarChar)]
        public string Details { get; set; }
        #endregion


        public static bool AddHRLog(HRLog hrLog)
        {
            List<SqlParameter> parms = Convert<SqlParameter>.ObjectToParms(hrLog);
            try
            {
                if (DataAccess.ExecuteNonQuery(CommandType.StoredProcedure, ADDHRLOG, parms.ToArray()) > 0)
                    return true;
            }
            catch (Exception ex)
            {
                
            }
            return false;
        }

        public static bool EditHRLog(HRLog hrLog)
        {
            List<SqlParameter> parms = Convert<SqlParameter>.ObjectToParms(hrLog);
            try
            {
                if (DataAccess.ExecuteNonQuery(CommandType.StoredProcedure, EDITHRLOG, parms.ToArray()) > 0)
                    return true;
            }
            catch (Exception ex)
            {
                Log.WriteLog("BU.EditHRLog", ex.Message, ex.StackTrace);
            }
            return false;
        }

        public static bool DelHRLog(HRLog hrLog)
        {
            List<SqlParameter> parms = Convert<SqlParameter>.ObjectToParms(hrLog);
            try
            {
                if (DataAccess.ExecuteNonQuery(CommandType.StoredProcedure, DELHRLOG, parms.ToArray()) > 0)
                    return true;
            }
            catch (Exception ex)
            {
                Log.WriteLog("BU.DelHRLog", ex.Message, ex.StackTrace);
            }
            return false;
        }
    }
}
